package com.fujifilm.project.plan.utils;

import lombok.Getter;

/**
 * 
 * 
 * @date 2025年6月05日
 * @time 21:59:10
 * @description
 * 
 */
@Getter
public class HttpResponse<T> {
    private HttpResponse() {
        // 默认构造函数
    }

    private String message;
    // 状态码
    // 200 成功
    // 其他错误
    private int code;

    private T data;

    public static <T> HttpResponse<T> success(T data) {
        HttpResponse<T> response = new HttpResponse<>();
        response.data = data;
        response.code = 200; // 成功状态码
        response.message = "Success";
        return response;
    }

    public static <T> HttpResponse<T> error(String message) {
        HttpResponse<T> response = new HttpResponse<>();
        response.code = 0; // 错误状态码
        response.message = message;
        return response;
    }

    public static <T> HttpResponse<T> error(int code, String message) {
        HttpResponse<T> response = new HttpResponse<>();
        response.code = code;
        response.message = message;
        return response;
    }
}
